<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增库存明细')" />
</head>
<body  >
<div class="container-div">
    <el-divider content-position="left" style="margin-bottom: 20px">库存明细信息</el-divider>
    <el-form  :inline="true"  label-position="left" :model="insert.boxItem.info" ref="insertForm" label-width="120px" :rules="insert.boxItem.rules" class="demo-ruleForm">

<!--        <el-form-item   label="子库存号" >-->
<!--            <el-input v-model="insert.boxItem.info.subInventoryCode"></el-input>-->
<!--        </el-form-item>-->

        <el-form-item   label="物料编码" >
            <el-input v-model="insert.boxItem.info.itemCode"></el-input>
        </el-form-item>

<!--        <el-form-item   label="物料描述" >-->
<!--            <el-input v-model="insert.boxItem.info.itemName"></el-input>-->
<!--        </el-form-item>-->

<!--        <el-form-item   label="当前位置" >-->
<!--            <el-input v-model="insert.boxItem.info.location"></el-input>-->
<!--        </el-form-item>-->

        <el-form-item   label="箱号" >
            <el-input v-model="insert.boxItem.info.boxCode"></el-input>
        </el-form-item>

        <el-form-item   label="批次" >
            <el-input v-model="insert.boxItem.info.batch"></el-input>
        </el-form-item>

        <el-form-item   label="数量（张）" >
            <el-input v-model="insert.boxItem.info.quantity"></el-input>
        </el-form-item>

        <el-form-item label="过期日期" >
            <el-col :span="11">
                <el-date-picker type="date" placeholder="选择日期" value-format="yyyy-MM-dd" v-model="insert.boxItem.info.exp1" style="width: 100%;"></el-date-picker>
            </el-col>
            <el-col :span="11">
                <el-time-picker placeholder="选择时间" value-format="HH:mm:ss" v-model="insert.boxItem.info.exp2" style="width: 100%;"></el-time-picker>
            </el-col>
        </el-form-item>

<!--        <el-form-item   label="铜箔厚度(毫米)" >-->
<!--            <el-input v-model="insert.boxItem.info.totalThickness"></el-input>-->
<!--        </el-form-item>-->

<!--        <el-form-item   label="子库" >-->
<!--            <el-input v-model="insert.boxItem.info.subInventoryName"></el-input>-->
<!--        </el-form-item>-->

<!--        <el-form-item label="子库">-->
<!--            <el-select v-model="insert.boxItem.info.forSubinventory" placeholder="请选择子库">-->
<!--                <el-option v-for="(item, index) in rows" :key="index" :label="item.subInventoryName" :value="item.subInventoryId"></el-option>-->
<!--            </el-select>-->
<!--        </el-form-item>-->

<!--        <select id="forSubinventory" name="forSubinventory" class="form-control">-->
<!--            <option v-for="(item, index) in rows" :key="index" :value="item.subInventoryId"-->
<!--                    selected="[[${forSubinventory}]] == item.subInventoryId? true:false"-->
<!--            >-->
<!--                {{item.subInventoryName}}-->
<!--            </option>-->
<!--        </select>-->

    </el-form>
    <div style="margin-left: 40%">
        <el-button type="primary" @click="save()">保存</el-button>
        <el-button type="info" @click="closeModal()">返回</el-button>
    </div>
</div>

<div th:include="include::footer"></div>
<script type="text/javascript" charset="UTF-8">
    var prefix = ctx + "in/boxItem"
    var app = new Vue({
        el: '.container-div',
        data: {
            insert:{
                boxItem:{
                    info:{},
                    rules:{

                    }
                }
            }
        },
        methods:{
            /*关闭此页面*/
            closeModal:function(){
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
            },
            save:function(){
                var that = this;
                /*校验billMaster数据*/
                this.$refs['insertForm'].validate((valid) => {
                    if (valid) {
                        var data = JSON.stringify(that.insert.boxItem.info)

                        $.ajax({
                            cache : true,
                            type : "POST",
                            url :  "/in/boxItem/add",
                            data : data,
                            dataType:"json",
                            contentType: "application/json;charset-UTF-8",
                            async : false,
                            beforeSend: function () {
                            	$.modal.loading("正在处理中，请稍后...");
                            },
                            error : function(request) {
                                $.modal.alertError(request.msg);
                                $.modal.closeLoading();
                            },
                            success : function(data) {
                                $.modal.alertSuccess("保存成功！");
                                that.closeModal();
                            }
                        });
                    }else{
                        return false;
                    }
                });
            }
        }
    })
</script>
</body>
</html>
